From f5e8b4093a1527967423a3af70f2b95d4b05008f Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Thu, 30 Dec 2021 23:40:37 +0100
Subject: prototype bots pages

---
 web/pw-server/src/routes/bots/[bot_id].svelte | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 web/pw-server/src/routes/bots/[bot_id].svelte

(limited to 'web/pw-server/src/routes/bots/[bot_id].svelte')

diff --git a/web/pw-server/src/routes/bots/[bot_id].svelte b/web/pw-server/src/routes/bots/[bot_id].svelte
new file mode 100644
index 0000000..90fd78d
--- /dev/null
+++ b/web/pw-server/src/routes/bots/[bot_id].svelte
@@ -0,0 +1,34 @@
+<script lang="ts" context="module">
+  import { get_session_token } from "$lib/auth";
+
+  export async function load({ page }) {
+    const token = get_session_token();
+    const res = await fetch(`/api/bots/${page.params["bot_id"]}`, {
+      headers: {
+        "Content-Type": "application/json",
+        Authorization: `Bearer ${token}`,
+      },
+    });
+
+    if (res.ok) {
+      return {
+        props: {
+          bot: await res.json(),
+        },
+      };
+    }
+
+    return {
+      status: res.status,
+      error: new Error("Could not load bot"),
+    };
+  }
+</script>
+
+<script lang="ts">
+  export let bot: object;
+</script>
+
+<div>
+  {bot["name"]}
+</div>
-- 
cgit v1.2.3

